/*
* @Author: taosong
* @Date:   2018-07-20 13:58:01
* @Last Modified by:   taosong
* @Last Modified time: 2018-07-20 14:38:24
*/
import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router,Switch,Route,Redirect,Link} from 'react-router-dom';
//页面
import Home          from 'page/home/index.jsx';
import Login         from 'page/login/index.jsx';
import Layout        from 'component/layout/index.jsx';
import UserList      from 'page/user/index.jsx';
import ErrorPage     from 'page/error/index.jsx';
import ProductRouter from 'page/product/router.jsx';
import OrderList     from 'page/order/index.jsx';
import orderDetail   from 'page/order/detail.jsx';


class App extends React.Component{
     
     render(){
        let LayoutRouter = (
           <Layout>
                <Switch>
                    <Route exact path="/" component={Home}/>
                    <Route path="/product" component={ProductRouter}/>
                    <Route path="/product-category" component={ProductRouter}/>
                    <Route path="/order/detail/:orderNumber" component={orderDetail}/>
                    <Route path="/order/index" component={OrderList}/>
                    <Route path="/user/index" component={UserList}/>
                    <Redirect exact from="/order" to="/order/index"/>
                    <Redirect exact from="/user" to="/user/index"/>{/*如果点击的是user会跳到后面的路径*/}
                    <Route component={ErrorPage}/>
                </Switch>
           </Layout>
        );
     	return (
     		<Router>
     		    <Switch>
     		        <Route path="/login" component={Login}/>
     		        <Route path="/" render = { props => LayoutRouter }/>
     		    </Switch>
     		</Router>
     	);
     }
}

ReactDOM.render(
	<App/>,
    document.getElementById('app')
	);

